<%@ page contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
function saveSiteType(){
	if ($('#frmSiteType').form('validate')){
		var data = $('#frmSiteType').serialize();
		var typecode = $('#frmSiteType input[name="typecode"]').val();
		var typename = $('#frmSiteType input[name="typename"]').val();
		$.ajax({
			url: '<c:url value="/system/site/sitetype/saveSiteType.do"/>',
			type: 'POST',
			data: data,
			beforeSend: function(XmlHttpRequest, textStatus, errorThrown) {
				$.messager.progress({
					title:'提示',
					msg:'正在执行数据操作，请稍待...'
				});
			},
			success: function(result) {
				$.messager.progress('close');
				if(result.success){
					$('#dlgAddSiteType').dialog('close').remove();
					$('#sitetypeList').datagrid('clearSelections').datagrid('reload');
					var node = $('#tree_sitetype').tree('getSelected');  //组织节点须选中
					if (node == null){
						node = $('#tree_sitetype').tree('getRoot');
					}
					
					<c:choose>
					<c:when test="${ref.saveType=='modify'}">
					$('#tree_sitetype').tree('reload', node.target);
					</c:when>
					<c:otherwise>
					$('#tree_sitetype').tree('append',{
						parent: (node?node.target:null),
						data:[{
							id: typecode,
							text: typename
						}]
					});
					</c:otherwise>
					</c:choose>
					$.messager.alert('提示', result.data , 'info');
				}
				else{
					$.messager.alert('错误', result.data , 'error');
				}
			}
		});
	}
}
</script>
<div style="padding: 5px;">
	<form id="frmSiteType" method="post" style="margin:0;padding:0">
	<table align="center" >
		<tr>
			<td>分类名称：</td>
			<td>
				<input id="typename" name="typename" style="width:200px" value="${SiteType.typename }" class="easyui-validatebox text" required="true" />		
				<input type="hidden" name="id" id="id" value="${SiteType.id }" />
			</td>
			<td>分类编码：</td>
			<td>
				<input id="typecode" name="typecode" style="width:200px"  value="${SiteType.typecode }" class="easyui-validatebox text" required="true" readonly="readonly"/>		
			</td>
		</tr>
		<tr>
			<td>上级编码：</td>
			<td>
				<input id="parentname" name="parentname" style="width:200px" value="${Name.name }" class="easyui-validatebox text" readonly="readonly"/> 	
				<input type="hidden" name="parentcode" id="parentcode" value="${SiteType.parentcode }" style="width:200px"  />
			</td>
			<td>排序：</td>
			<td>
				<input id="typesort" name="typesort" style="width:200px" value="${SiteType.typesort }" class="easyui-validatebox easyui-numberbox" />		
			</td>
		</tr>
		<tr>
			<td>关键字：</td>
			<td colspan="3">
				<textarea id="keyword" name="keyword" rows="3" cols="80">${SiteType.keyword }</textarea>
			</td>
		</tr> 
		<tr>
			<td>状态：</td>
			<td colspan="3">
				<select class="easyui-combobox" id="typestate" name="typestate" editable="false" panelHeight="auto" name="status" required="true" style="width:200px;">  
					    <option value="1" <c:if test="${SiteType.typestate == 1}">selected="selected"</c:if>>启用</option>  
					    <option value="0" <c:if test="${SiteType.typestate == 0}">selected="selected"</c:if>>禁用</option>  
				</select>
			</td>
		</tr>
	</table>
	</form>
</div>